/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoo360.mobilesafe.utils;

import android.content.Context;
import android.content.res.AssetManager;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;

public class Utils {
    private static final String TAG = "Utils";
    private static final boolean DEBUG = 0;

    public static void copyAssetsFile(Context paramContext, String paramString, File paramFile) {
        copyFile(paramContext.getAssets().open(paramString), paramFile);
    }

    public static void copyFile(InputStream paramInputStream, File paramFile) {
        FileOutputStream localFileOutputStream = null;
        try {
            localFileOutputStream = new FileOutputStream(paramFile);
            byte[] arrayOfByte = new byte[1024];
            int i = 0;
            while ((i = paramInputStream.read(arrayOfByte)) != -1)
                localFileOutputStream.write(arrayOfByte, 0, i);
            localFileOutputStream.flush();
        } finally {
            if (localFileOutputStream != null)
                try {
                    localFileOutputStream.close();
                } catch (Exception localException1) {}
            if (paramInputStream != null)
                try {
                    paramInputStream.close();
                } catch (Exception localException2) {}
        }
    }

    public static boolean checkFileDir(Context paramContext) {
        File localFile = paramContext.getFilesDir();
        if ((!(localFile.exists())) && (!(localFile.mkdirs())))
            return false;
        return ((localFile.exists()) && (localFile.isDirectory()));
    }
}